package com.dragon.demo;

/**
 * @author dragon
 * @version V1.0.0-RELEASE
 * @date 2019/5/22 21:10
 */
public class SumTest {

    public static void main(String[] args) {
        System.out.println(getSum(100));
        System.out.println(getSum());
    }

    public static int getSum(int num) {
        if (num == 1) {
            return num;
        }

        return num + getSum(num - 1);
    }

    public static int getSum() {
        int result = 0;
        for (int i = 1; i <= 100; i++) {
            result += i;
        }

        return result;
    }
}
